<template>
	<view class="card">
		<!-- 顶部标题 -->
		<view class="card-header">
			<text class="paid">付费精选课程</text>
		</view>

		<!-- 主体内容 -->
		<view class="card-body">
			<!-- 左侧视频封面 -->
			<image class="video-img" src="@/static/video_preview/专业团队.png" />
			<!-- 右侧信息 -->
			<view class="video-info">
				<!-- 视频名称，限制长度 -->
				<text class="video-title">{{ truncate(video.videoName, 10) }}</text>

				<!-- 视频简介 -->
				<text class="video-remake">{{ video.teacher.teacherName }} |
					{{ truncate(video.videoRemake, 6) }}</text>

				<!-- 价格和按钮 -->
				<view class="price-button">
					<text class="price">{{ video.price }} ￥</text>
					<button class="learn-button" @click="handleLearnClick">前往学习</button>
				</view>
			</view>
		</view>

		<!-- 特点展示 -->
		<view class="features">
			<!-- 特点1 -->
			<text class="feature-item">
				<image src="/static/alibaba_icon/OK.svg" mode="widthFix" style="width:12px; height:12px;" />
				高清画质
			</text>
			<!-- 特点2 -->
			<text class="feature-item">
				<image src="/static/alibaba_icon/OK.svg" mode="widthFix" style="width:12px; height:12px;" />
				名师讲解
			</text>
			<!-- 特点3 -->
			<text class="feature-item">
				<image src="/static/alibaba_icon/OK.svg" mode="widthFix" style="width:12px; height:12px;" />
				终身学习
			</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			video: {
				type: Object,
				required: true
			}
		},
		methods: {
			truncate(text, length) {
				return text.length > length ? text.slice(0, length) + "..." : text;
			},
			handleLearnClick() {
				// 将 video 设置为全局的 videoAbout
				this.$store.commit("setVideoAbout", this.video);
				// 跳转到 /pages/pay_video/index 页面
				uni.navigateTo({
					url: "/pages/pay_video/index"
				});
			}
		}
	};
</script>

<style scoped>
	.card {
		min-width: 200px;
		border-radius: 10px;
		background-color: #1a1a1a;
		box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
		overflow: hidden;
		margin: 10px;
		border: 1px solid #333;
		color: #f1f1f1;
	}

	.card-header {
		border-radius: 10px;
		padding: 8px;
		font-weight: bold;
		font-size: 14px;
		background-color: #333;
		color: #ffcc00;
		text-align: center;
	}

	.paid {
		color: #ffcc00;
	}

	.card-body {
		display: flex;
		padding: 10px;
	}

	.video-img {
		width: 80px;
		height: 80px;
		border-radius: 8px;
		object-fit: cover;
		margin-right: 10px;
		box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.5);
	}

	.video-info {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		flex: 1;
	}

	.video-title {
		font-size: 16px;
		font-weight: bold;
		color: #f1f1f1;
		margin: 0;
	}

	.video-remake {
		font-size: 12px;
		color: #cccccc;
		margin: 5px 0;
		height: 30px;
	}

	.price-button {
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.price {
		font-size: 18px;
		color: #ffcc00;
		font-weight: bold;
	}

	.learn-button {
		padding: 0px 20px;
		background-color: #ffcc00;
		color: #1a1a1a;
		font-size: 12px;
		border: none;
		border-radius: 20px;
		cursor: pointer;
		margin-right: 0px;
	}

	.learn-button:hover {
		background-color: #e6b800;
	}

	.features {
		display: flex;
		justify-content: space-around;
		padding: 10px;
		border-top: 1px solid #666;
	}

	.feature-item {
		display: flex;
		align-items: center;
		font-size: 11px;
		color: #cccccc;
	}
</style>
